<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>类的继承</title>
	<script type="text/javascript">
		function Fclass(name,age){
			this.name = name;
			this.age = age;
		}

		Fclass.prototype.showname = function(){
			alert(this.name);
		}

		Fclass.prototype.showage = function(){
			alert(this.age);
		}

		function Sclass(name,age,job){
			// 这是继承属性的关键
			// 最终指向子类实例化对象，使用call或apply继承
			Fclass.call(this,name,age);
			this.job = job;
		}

		// 这是方法继承的关键，也就是将子类的方法指向父类的实例
		Sclass.prototype = new Fclass();

		Sclass.prototype.showjob = function(){
			alert(this.job);
		}

		var Tom = new Sclass('tom',18,'worker');
	</script>
</head>
<body>
	
</body>
</html>